%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/basics"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 47, 11, 14<br />2: PgSelect[8], PgSelect[19]<br />ᐳ: Access[29]<br />3: Connection[12], PgSelectRows[21]<br />ᐳ: 20, 22, 23<br />4: ConnectionItems[15]<br />ᐳ: 28, 30, 31, 32"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 29, 15, 11, 23, 30, 32<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 29, 11<br /><br />ROOT __Item{3}ᐸ15ᐳ[24]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 24, 25, 11, 34<br /><br />ROOT Edge{3}[25]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 35, 11<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[35]<br />1: <br />ᐳ: 36, 37<br />2: PgSelect[38]<br />3: PgSelectRows[43]<br />ᐳ: First[42], PgSelectSingle[44]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 44<br /><br />ROOT PgSelectSingle{5}ᐸusersᐳ[44]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda14{{"Lambda[14∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[47]"}}:::plan
    Lambda14 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    PgSelect19[["PgSelect[19∈0] ➊<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda14 --> PgSelect19
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ<br />Dependents: 4"]]:::plan
    PgSelect8 --> Connection12
    ConnectionItems15[["ConnectionItems[15∈0] ➊<br />Dependents: 3<br />More deps:<br />- Connection[12]"]]:::plan
    First20{{"First[20∈0] ➊"}}:::plan
    PgSelectRows21[["PgSelectRows[21∈0] ➊"]]:::plan
    PgSelectRows21 --> First20
    PgSelect19 --> PgSelectRows21
    PgSelectSingle22{{"PgSelectSingle[22∈0] ➊<br />ᐸmessagesᐳ"}}:::plan
    First20 --> PgSelectSingle22
    First28{{"First[28∈0] ➊<br />More deps:<br />- ConnectionItems[15]"}}:::plan
    Access29{{"Access[29∈0] ➊<br />ᐸ8.cursorDetailsᐳ<br />Dependents: 3"}}:::plan
    PgSelect8 --> Access29
    Last31{{"Last[31∈0] ➊<br />More deps:<br />- ConnectionItems[15]"}}:::plan
    PageInfo18{{"PageInfo[18∈1] ➊<br />More deps:<br />- Connection[12]"}}:::plan
    Access26{{"Access[26∈1] ➊<br />ᐸ12.hasNextPageᐳ<br />More deps:<br />- Connection[12]"}}:::plan
    Access27{{"Access[27∈1] ➊<br />ᐸ12.hasPreviousPageᐳ<br />More deps:<br />- Connection[12]"}}:::plan
    Edge25{{"Edge[25∈3]"}}:::plan
    __Item24[/"__Item[24∈3]<br />ᐸ15ᐳ<br />More deps:<br />- ConnectionItems[15]"\]:::itemplan
    PgCursor34{{"PgCursor[34∈3]<br />More deps:<br />- Access[29]"}}:::plan
    __Item24 & PgCursor34 --> Edge25
    __Item24 --> PgCursor34
    PgSelectSingle35{{"PgSelectSingle[35∈4]<br />ᐸmessagesᐳ"}}:::plan
    __Item24 --> PgSelectSingle35
    PgSelect38[["PgSelect[38∈5]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression37{{"PgClassExpression[37∈5]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression37 --> PgSelect38
    PgClassExpression36{{"PgClassExpression[36∈5]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle35 --> PgClassExpression36
    PgSelectSingle35 --> PgClassExpression37
    First42{{"First[42∈5]"}}:::plan
    PgSelectRows43[["PgSelectRows[43∈5]"]]:::plan
    PgSelectRows43 --> First42
    PgSelect38 --> PgSelectRows43
    PgSelectSingle44{{"PgSelectSingle[44∈5]<br />ᐸusersᐳ"}}:::plan
    First42 --> PgSelectSingle44
    PgClassExpression45{{"PgClassExpression[45∈6]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle44 --> PgClassExpression45
    PgClassExpression46{{"PgClassExpression[46∈6]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression45 o--o PgClassExpression46

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,Lambda14,ConnectionItems15,PgSelect19,First20,PgSelectRows21,PgSelectSingle22,First28,Access29,Last31 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo18,Access26,Access27 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item24,Edge25,PgCursor34 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle35 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression36,PgClassExpression37,PgSelect38,First42,PgSelectRows43,PgSelectSingle44 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression45,PgClassExpression46 bucket6

